﻿// *----------------------------------------------------------------
// Copyright (C) 2017 通通优品
// 版权所有。
// 
// 类名：CacheManagerSettingExtensions.cs
// 功能描述：TongTongMall
// 
// Create User：jym 2017/02/09
// 
// Edit User：UserName,EditTime
// Describe：Describe
// ----------------------------------------------------------------*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TongTongMall.Runtime.Caching;
using TongTongMall.Tenant;

namespace TongTongMall.Configuration
{
    public static class CacheManagerSettingExtensions
    {
        /// <summary>
        /// 获取全局配置缓存对象
        /// </summary>
        public static ITypedCache<string, Dictionary<string, SettingInfo>> GetApplicationSettingsCache(this ICacheManager cacheManager)
        {
            return cacheManager
                .GetCache<string, Dictionary<string, SettingInfo>>(TenantCacheName.ApplicationSettings);
        }

        /// <summary>
        /// 获取租户配置缓存对象.
        /// </summary>
        public static ITypedCache<string, Dictionary<string, SettingInfo>> GetTenantSettingsCache(this ICacheManager cacheManager)
        {
            return cacheManager
                .GetCache<string, Dictionary<string, SettingInfo>>(TenantCacheName.TenantSettings);
        }

        /// <summary>
        /// 获取用户配置缓存对象.
        /// </summary>
        public static ITypedCache<string, Dictionary<string, SettingInfo>> GetUserSettingsCache(this ICacheManager cacheManager)
        {
            return cacheManager
                .GetCache<string, Dictionary<string, SettingInfo>>(TenantCacheName.UserSettings);
        }
    }
}
